using System;
using System.Data;
using BeeldBank.Data.Sql;
using System.Data.SqlClient;

namespace BeeldBank.Data
{
	/// <summary>
	/// Provides database independant methods for Order.
	/// </summary>
	public class Order : OrderBase
	{


		public static int OpenOrderIdForUser ( int UserId )
		{
			int returnValue = 0;
			SqlParameter[] sqlParamArray = new SqlParameter[1];



			sqlParamArray[ 0 ] = new SqlParameter( "@UserId", SqlDbType.Int );
			sqlParamArray[ 0 ].Value = UserId;
			

			DataTable dt = OpenParamArray( "BEELDBANK_CUSTOM_ORDER_SELECT_OPEN_ORDER_FOR_USER", sqlParamArray, null );
			if ( dt.Rows.Count != 0 ) {

				try {
					returnValue = Convert.ToInt32( dt.Rows[ 0 ][ 0 ].ToString() );
				} catch ( Exception ) {
					returnValue = 0;
				}
			}


			return returnValue;
		}

	}
}
